package com.example.vote.controller;

import com.example.vote.service.BizException;
import com.yc.vcode.bean.Result;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

@Component
@RestControllerAdvice
public class VoteExceptionHandler {

    @ExceptionHandler(BizException.class)
    public Result BizExceptionHandler(BizException e){
        e.printStackTrace();
        return new Result(0, e.getMessage(), null);
    }

    @ExceptionHandler(Exception.class)
    public Result ExceptionHandler(Exception e){
        e.printStackTrace();
        return new Result(0, "业务繁忙,请稍候再试!", null);
    }
}
